package com.ccb.channel.convert;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.bson.BasicBSONObject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccb.util.StandardRecord;
import com.mongodb.hadoop.io.BSONWritable;

public class ConvertMapper  extends Mapper<LongWritable, Text, Text, BSONWritable>{
	public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		String val=value.toString().trim();
		StandardRecord standardRecord= null;
		standardRecord= JSON.parseObject(val.toString(), StandardRecord.class);
		JSONObject request=standardRecord.getRequestData();
		
		//jiekou      String convertContext=ConvertUtil.convert(standardRecord.getrequest);
		
		
		//JSONObject js=
		BasicBSONObject bsonObject = new BasicBSONObject();
		//bsonObject.append(request)
		
		context.write(new Text(standardRecord.getUid()), new BSONWritable(bsonObject));
	}

}
